package cn.com.miao.lynx.service.system.entity;

import cn.com.miao.lynx.common.base.model.BaseModel;
import cn.com.miao.lynx.common.core.constant.LogType;
import lombok.*;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * SysLog
 * 系统日志实体
 * @title: SysLog
 * @description: 系统日志实体
 * @author: dengmiao
 * @create: 2019-12-27 11:34
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = SysLog.TABLE_NAME)
@SQLDelete(sql = SysLog.LOGIC_DELETE_STATEMENT)
@Where(clause = "del_status = " + SysLog.DELETE_FLAG_NORMAL)
public class SysLog extends BaseModel<Long> {

    public final static String TABLE_NAME = "sys_log";

    public final static String LOGIC_DELETE_STATEMENT = "update " + TABLE_NAME + " set del_status = " + SysLog.DELETE_FLAG_DELETE + " where id = ?";

    /**
     * 日志类型
     */
    @Convert(converter = LogType.Converter.class)
    private LogType type;

    /**
     * 标题描述
     */
    private String title;

    /**
     * 操作IP地址
     */
    private String remoteAddr;
    /**
     * 用户代理
     */
    private String userAgent;
    /**
     * 请求URI
     */
    private String requestUri;
    /**
     * 操作方式
     */
    private String method;
    /**
     * 方法名
     */
    private String methodName;
    /**
     * 操作提交的数据
     */
    private String params;
    /**
     * 执行时间
     */
    private Long time;

    /**
     * 异常信息
     */
    private String exception;
}
